<!DOCTYPE html>
<html>
<title>菜单管理</title>
<head>
    <link href="/css/layui/css/layui.css" rel="stylesheet">
    <link href="/css/hadmin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="/css/hadmin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/hadmin/css/animate.css" rel="stylesheet">
    <link href="/css/hadmin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/css/hadmin/css/animate.css" rel="stylesheet">
    <link href="/css/bootstrap-select.min.css" rel="stylesheet">
    <link href="/css/multi-select.dist.css" rel="stylesheet">
</head>
<article class="page-container" style="margin: 20px">
    <input class="checkbox1" id="selectAll" type="checkbox" name="" value="">全选
    <form action="/role/authSave" method="post" class="form form-horizontal" id="form-role-add">
        <input type="hidden"  name="id" value="<?=$id ?>">
        <?php foreach($list as $v): ?>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <input class="checkbox1"  data-id="<?= $v['id'] ?>" type="checkbox"
                           <?php if($v['status'] == 1): ?> checked <?php endif; ?> name="auth[]" value="<?=$v['id']?>">
                    <?= $v['auth_name']; ?>
                </div>
                <?php foreach($v['son'] as $vv): ?>
                    <div class="panel-body" style="margin: 5px">
                        <input class="checkbox1" id="<?=$vv['id'];?>" data-id="<?=$vv['pid'];?>" type="checkbox"
                            <?php if($vv['status'] == 1): ?> checked <?php endif; ?> name="auth[]" value="<?=$vv['id']?>">
                        <?= $vv['auth_name']; ?>
                            <?php if(!empty($vv['son'])): ?>
                                <div style="padding:10px;border: 1px solid #ddd">
                                    <?php foreach($vv['son'] as $vvv): ?>
                                    <input class="checkbox1" id="<?=$vvv['id'];?>" data-id="<?=$vvv['pid'];?>" type="checkbox"
                                    <?php if($vvv['status'] == 1): ?> checked <?php endif; ?> name="auth[]" value="<?=$vvv['id']?>">
                                    <?= $vvv['auth_name']; ?>
                                    <?php endforeach; ?>
                                </div>
                            <?php endif; ?>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endforeach; ?>

        <div class="row cl">
            <div style="margin: 20px">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<script src="/css/hadmin/js/jquery.min.js?v=2.1.4"></script>
<script src="/css/hadmin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/css/hadmin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/css/hadmin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/css/hadmin/js/plugins/layer/layer.min.js"></script>
<script src="/css/hadmin/js/index.js"></script>
<script src="/css/hadmin/js/plugins/toastr/toastr.min.js"></script>
<script src="/js/jquery.fancybox.min.js"></script>
<script src="/js/cupload.js"></script>

<script>
    $("#selectAll").click(function () {
        if (this.checked) {
            $(".checkbox1").prop("checked", true);
        } else {
            $(".checkbox1").prop("checked", false);
        }
    });

    $(".checkbox1").click(function () {
        var className = $(this).parent().attr('class');
        var dom = "";
        var dom1 = "";
        if (className == "panel-body") {
            dom = $(this).parent('div').find("input.checkbox1");
            dom1 = $(this).parent().siblings('div.panel-heading').find("input.checkbox1");
        } else if (className == "panel-heading") {
            dom = $(this).parent('div').siblings().find("input.checkbox1");
        } else {
            dom = $(this).parent('div').siblings();
            dom1 = $(this).parent().parent().siblings('div.panel-heading').find("input.checkbox1");
        }
        if (this.checked) {
            dom.prop("checked", true);
            if(className != "panel-heading")
            dom1.prop("checked", true);
        } else {
            dom.prop("checked", false);
            if(className != "panel-heading")
            dom1.prop("checked", false);
        }
    })
</script>